﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using OTA.Notification.BO.Dictionary;
using OTA.Notification.Entity.Dictionary;

using System.Collections.Generic;
using EZCRS.HCMS.Bll.AIR;
using OTA.Notification.Entity.Event;
using Strive.DataAccess.Base.BO;
using EZCRS.HCMS.Bll;

namespace OTA.Notification.Web.Message
{
    public partial class SendMsg : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {

            //类型加载

            using (DictionaryBO bo = new DictionaryBO())
            {

                IList<OTA_DICTIONARY> lstType = bo.getAllDictionary("Send", OTA.Notification.Common.DicType.Message, OTA.Notification.Common.LanguageType.Chinese);

                ddlMsgSendType.Items.Insert(0, new ListItem("--发送类型--", ""));

                foreach (OTA_DICTIONARY dic in lstType)
                    ddlMsgSendType.Items.Add(new ListItem(dic.NAME, dic.VALUE.ToString()));
            }

        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            int iDelay = 0;
            int iSecond = 0;

            int.TryParse(txtDelay.Text, out iDelay);
            int.TryParse(txtiInterval.Text, out iDelay);

            iSecond = iSecond * 60;

            using (OTAMessageEventBO _eventBO = new OTAMessageEventBO())
            {
                MsgEventBean bean = new MsgEventBean();

                bean.AppCode = "HCRS";
                bean.CreateTime = DateTime.Now;
                bean.Level = "L";
                bean.MsgContent = txtMsg.Text;
                //bean.MsgTemplate = notifyobj.TemplateID;
                bean.MsgSendType = ddlMsgSendType.SelectedValue;
                bean.MsgTitle = txtTitle.Text;
                bean.Delay = iDelay;
                bean.DelayType = 1;
                bean.DelaySecond = iSecond;

                //bean.ReceiverAccount = IATA;

                // _eventBO.IsNew = true;

                SaveAction sa = _eventBO.Save(bean);

            }

            Response.Write(CFun.AlertMeg(Resources.Site.Success, "non", ""));

        }
    }
}
